﻿namespace SimpleBehaviorTreeLibrary
{
    public abstract class Sequence : ComplexComposite
    {
        public override RunResult Run(Blackboard blackboard)
        {
            Status = TaskStatus.Running;

            foreach (var child in Children)
            {
                if (child.Run(blackboard) == RunResult.Failure)
                {
                    Status = TaskStatus.Ready;

                    return RunResult.Failure;
                }
            }

            Status = TaskStatus.Ready;

            return RunResult.Success;
        }
    }
}
